﻿<html>

<head>

<!--COMMON :include style and javascript code-->
${inc:/action/pub/common}

<title>费用发放记录信息</title>

</head>

<body onmouseup="hidInputValidatorTip(3);">
<!--a name="A0" id="A0"></a-->

<!--COMMON HEADER-->
${inc:/action/pub/header}

<center>

<!--filter form-->
<div id="divFilter" style="display:none;width:100%">
</div>

<!--addnew/edit form-->
<div id="divEditor" style="display:none;width:100%">
</div>

<!--insert/update response-->
<div id="divEditorResponse" style="display:none;width:100%">
</div>

<!--grid view response-->
<div id="response" style="display:none;width:100%">
</div>

<!--progress indicator-->
<div id="divStatus" class="alert" style="text-align:left; display:none;color:gray;width:150px;font-weight:bold;font-family:Arial">
	<img src="${def:context}/images/progress.gif"> 请稍候...
</div>

<!--show linked grid-->
<iframe id="detail" name="detail" marginwidth="0" scrolling="no" frameborder="0" style="height:0%;width:100%;visibility:hidden">
</iframe>

<!--用于传递当前目录到header模版中-->
<input type="hidden" name="actionroot" id="actionroot" value="${def:actionroot}">

</center>

</body>

</html>

<SCRIPT LANGUAGE="JavaScript">

//字段校验
function checkFields(){
    if(CheckNull("master_name","formEditor","户主不能为空！")) return false;
    if(CheckNull("banjia_fee","formEditor","搬家费不能为空！")) return false;
    if(CheckNull("touqin_fee","formEditor","投亲费不能为空！")) return false;
    if(CheckNull("suqian_fee","formEditor","速迁费不能为空！")) return false;
    return true;
}
</SCRIPT>



<script type="text/javascript">


function searchBack(){
    document.getElementById("divFilter").style.display = "";
    return true;
}

function addNewBackSetting(){
    return true;
}

loadEditor();
loadFilter(search);

</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
    function parseFloatExtend(val){
        if(val == ""){
            return 0;
        }
        return Math.round(parseFloat(val)*100)/100;
    }
    //合计
    function evalTotal(){
        var banjia_fee = document.formEditor.banjia_fee.value;
        var touqin_fee = document.formEditor.touqin_fee.value;
        var suqian_fee = document.formEditor.suqian_fee.value;
        var other_fee = document.formEditor.other_fee.value;

        var total_fee = document.formEditor.total_fee;
        total_fee.value = parseFloatExtend(banjia_fee)+parseFloatExtend(touqin_fee)+parseFloatExtend(suqian_fee)+parseFloatExtend(other_fee);
    }

    //根据投亲开始时间，投亲月份数，计算出投亲结束日期
    function evalEnddate(){
        //校验begin_date
        if(CheckNull("begin_date","formEditor","开始时间不能为空！")) return false;
        //if(CheckNull("month_count","formEditor","投亲月份数不能为空！")) return false;
        if (!CheckNum2("month_count","formEditor")) return false;


        var begin_date = document.formEditor.begin_date.value;
        var month_count = document.formEditor.month_count.value;


        var new_BeginDate = begin_date.replace(/-/g, "\/");
        var date = new Date(new_BeginDate);
        var lIntval = parseInt(month_count);
        date.setMonth(date.getMonth() + lIntval);
        
        var ret = date.getFullYear() +'-' + (date.getMonth()+1) + '-' +date.getDate();
        document.formEditor.end_date.value = ret;
        document.formEditor.touqin_fee.value = 700 * lIntval;
    }

    //根据开始时间、结束时间计算月份数
    function calMonthCount(){
        //校验
        //校验：价格
        //if(!CheckNum("month_price","formEditor")){
        //    return;
        //}

        //校验：时间
        var begin_date = document.getElementById("begin_date").value;
        var end_date = document.getElementById("end_date").value;

        if(!CheckLength("begin_date")){
            return;
        }
        if(!CheckLength("end_date")){
            return;
        }
        
        //
        var beginDate_day;
        var endDate_dya;

        beginDate = begin_date.replace(/-/g, "\/");//转换
        endDate   = end_date.replace(/-/g, "\/");
        var   etime=   new   Date(endDate);
        var   btime=   new   Date(beginDate);
        var   ilemonth   =   etime.getMonth() - btime.getMonth();
        var   ileyear=etime.getYear() - btime.getYear();
        var   ile=ileyear*12+ilemonth+1;
        if(ile<=0){
            alert("投亲开始时间、结束时间不合法!");
        }else{
            beginDate_day = btime.getDate();
            var i=0;
            if(beginDate_day>0 && beginDate_day<=10){
                i=1;
            }else if(beginDate_day>10 && beginDate_day<=20){
                i=0.5;
            }else if(beginDate_day>20){
                i=0;
            }

            //根据结束日期决定月份(1-10:0 11-20:0.5)
            endDate_day = etime.getDate();
            var j=0;
            if(endDate_day>0 && endDate_day<=10){
                j=0;
            }else if(endDate_day>10 && endDate_day<=20){
                j=0.5;
            }else if(endDate_day>20){
                j=1;
            }

            //月份数
            ile = ile-1+i;
            ile = ile-1+j;
            document.getElementById("month_count").value = ile;


            //计算投亲费用
            var month_price = document.forms["formEditor"].elements["month_price"];
            var selectedValue = month_price.options[month_price.selectedIndex].value;
            document.formEditor.touqin_fee.value = parseFloatExtend(parseFloat(selectedValue) * parseFloat(ile));
        }
    }
//小数点后留两位
function parseFloatExtend(val){
	if(val == ""){
		return 0;
	}
    return Math.round((parseFloat(val).toFixed(3))*100)/100;
}

function changeMyFocusByKey(up,down){
	var evt = getEvent();
	var keycode = evt.keyCode?evt.keyCode:evt.which;
	switch (keycode)
	{
		case 38:
			if(up == "") return;
			document.forms["formEditor"].elements[up].focus();
			document.forms["formEditor"].elements[up].select();
			break;
		case 40:
			if(down == "") return;
			document.forms["formEditor"].elements[down].focus();
			document.forms["formEditor"].elements[down].select();
			break;
	}
  }

  function getEvent() //同时兼容ie和ff的写法 
    {  
        if(document.all)  return window.event;    
        func=getEvent.caller;        
        while(func!=null){  
            var arg0=func.arguments[0]; 
            if(arg0) 
            { 
              if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) 
              {  
              return arg0; 
              } 
            } 
            func=func.caller; 
        } 
        return null; 
    } 
//-->
</SCRIPT>